<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function repeat(fn, n, nn) {
        let count = 0;
        return (str) => {
          const timeOut = setInterval(() => {
            if (count >= n) {
              clearInterval(timeOut);
            } else {
              fn(str);
              count++;
            }
          }, nn);
        };
      }

      const repeatFn = repeat(console.log, 4, 1000);
      repeatFn('Hello');
    </script>
  </body>
</html>
